package com.title5;

import java.io.*;

/**
 * @Author milian
 * @Date 2021/8/4 0004 21:38
 */
public class title5 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student s1 = new Student("张三", 22, "男");
        Student s2 = new Student("张一", 42, "女");
        Student s3 = new Student("张二", 32, "男");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("H:\\homework\\day13\\src\\com\\title5\\stu.txt"));
        oos.writeObject(s1);
        oos.writeObject(s2);
        oos.writeObject(s3);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("H:\\homework\\day13\\src\\com\\title5\\stu.txt"));
        Object len;
        try {
            while ((len=ois.readObject())!=null){
                System.out.println(len.toString());
            }
        } catch (EOFException e) {

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
